/*
    SPDX-FileCopyrightText: 2010 Martin Gräßlin <mgraesslin@kde.org>
    SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org>

    SPDX-License-Identifier: GPL-2.0-or-later
*/

#include "screenshotdbusinterfacekylin.h"

#include <KLocalizedString>

#include <QDBusConnection>
#include <QDBusConnectionInterface>
#include <QDBusReply>
#include <QDebug>
#include <QDir>
#include <QTemporaryFile>

#include <unistd.h>

namespace KWin
{
static const QString s_dbusServiceName = QStringLiteral("org.ukui.KWin");
static const QString s_dbusInterface = QStringLiteral("org.ukui.kwin.Screenshot");
static const QString s_dbusObjectPath = QStringLiteral("/Screenshot");

const static QString s_errorAlreadyTaking = QStringLiteral("org.ukui.kwin.Screenshot.Error.AlreadyTaking");
const static QString s_errorAlreadyTakingMsg = QStringLiteral("A screenshot is already been taken");
const static QString s_errorNotAuthorized = QStringLiteral("org.ukui.kwin.Screenshot.Error.NoAuthorized");
const static QString s_errorNotAuthorizedMsg = QStringLiteral("The process is not authorized to take a screenshot");
const static QString s_errorFd = QStringLiteral("org.ukui.kwin.Screenshot.Error.FileDescriptor");
const static QString s_errorFdMsg = QStringLiteral("No valid file descriptor");
const static QString s_errorCancelled = QStringLiteral("org.ukui.kwin.Screenshot.Error.Cancelled");
const static QString s_errorCancelledMsg = QStringLiteral("Screenshot got cancelled");
const static QString s_errorInvalidArea = QStringLiteral("org.ukui.kwin.Screenshot.Error.InvalidArea");
const static QString s_errorInvalidAreaMsg = QStringLiteral("Invalid area requested");
const static QString s_errorInvalidScreen = QStringLiteral("org.ukui.kwin.Screenshot.Error.InvalidScreen");
const static QString s_errorInvalidScreenMsg = QStringLiteral("Invalid screen requested");
const static QString s_dbusInterfaceName = QStringLiteral("org.ukui.kwin.Screenshot");
const static QString s_errorScreenMissing = QStringLiteral("org.ukui.kwin.Screenshot.Error.ScreenMissing");
const static QString s_errorScreenMissingMsg = QStringLiteral("Screen not found");

ScreenShotDBusInterfaceKylin::ScreenShotDBusInterfaceKylin(QObject *parent)
    : QObject(parent)
{
    QDBusConnection::sessionBus().registerObject(s_dbusObjectPath, this, QDBusConnection::ExportScriptableContents);
    QDBusConnection::sessionBus().registerService(s_dbusServiceName);
}

ScreenShotDBusInterfaceKylin::~ScreenShotDBusInterfaceKylin()
{
    QDBusConnection::sessionBus().unregisterService(s_dbusServiceName);
    QDBusConnection::sessionBus().unregisterObject(s_dbusObjectPath);
}

void ScreenShotDBusInterfaceKylin::screenshotForWindow(qulonglong winid, int mask)
{
    qWarning() << "[=== checkmode ===]"
               << "screenshotForWindow";
}

QString ScreenShotDBusInterfaceKylin::screenshotArea(int x, int y, int width, int height, bool captureCursor)
{
    qWarning() << "[=== checkmode ===]"
               << "screenshotArea";
    return QString();
}

} // namespace KWin

#include "screenshotdbusinterfacekylin.moc"
